package com.byl.modules.sys.service.impl;

import com.byl.modules.sys.dao.UserDao;
import com.byl.modules.sys.service.UserService;
import com.byl.sdk.bean.ResultBean;
import com.byl.sdk.utils.PageMap;
import com.byl.sdk.utils.UUIDUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * Created by Administrator on 2018/11/30.
 */
@SuppressWarnings("ALL")
@Service
public class UserServiceImpl implements UserService {

    @Autowired
    UserDao userDao;

    @Override
    public ResultBean listUser(Map<String, String> map) {
        PageMap pageMap = new PageMap(map);
        List list = userDao.listUser(pageMap);
        int total = userDao.listUserCount(pageMap);
        ResultBean bean = new ResultBean(pageMap.getPage(), pageMap.getPageSize(), total, list);
        return bean;
    }

    @Override
    public int saveUser(Map<String, String> map) {
        // java生成id
        map.put("id", UUIDUtils.generateUUID());
        map.put("usertype","1");
        map.put("status","1");
        return userDao.saveUser(map);
    }

    @Override
    public int editUser(Map<String, String> map) {
        return userDao.editUser(map);
    }

    @Override
    public int delUser(String id) {
        return userDao.delUser(id);
    }

    @Override
    public int chgUserStatus(String id) {
        return userDao.chgUserStatus(id);
    }

    @Override
    public int checkUser(String username) {
        return userDao.checkUser(username);
    }

    @Override
    public int updatePassword(Map map) {
        return userDao.updatePassword(map);
    }

    @Override
    public int resetpassword(String id) {
        return userDao.resetpassword(id);
    }
}
